package com.wenyu.wenyuyuedu.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

public class MyToast {
    private static Toast mToast;

    /**
     * 弹出Toast，处理单例的问题。
     *
     * @param context
     * @param text
     * @param lengthShort
     */
    public static void showToast(Context context, String text, int lengthShort) {
        if (mToast == null) {
            mToast = Toast.makeText(context, null, Toast.LENGTH_SHORT);
        }
        mToast.setDuration(lengthShort);
        mToast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 600);
        mToast.setText(text);
        mToast.show();
    }
}
